<% import grails.persistence.Event %>
<%=packageName%>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="grame">
		<g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
		<title><g:message code="default.show.label" args="[entityName]" /></title>
	</head>
	<body>
    <content tag="navbar">
        <li class="dropdown visible-xs">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Actions<span class="caret"></span></a>
            <ul class="dropdown-menu" role="menu">
                <li><g:link action="index"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
                <li><g:link action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
            </ul>
        </li>
    </content>
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-9">
                <div class="panel-group" id="show-${domainClass.propertyName}" role="main">
                    <h2 class="panel-heading"><g:message code="default.show.label" args="[entityName]" /></h2>
                    <g:if test="\${flash.message}">
                        <div class="alert alert-info" role="status">\${flash.message}</div>
                    </g:if>
                    <div class="panel-body">
                        <ol class="list-group">
                            <%  excludedProps = Event.allEvents.toList() << 'id' << 'version'
                            allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'
                            props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && (domainClass.constrainedProperties[it.name] ? domainClass.constrainedProperties[it.name].display : true) }
                            Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
                            props.each { p -> %>
                            <g:if test="\${${propertyName}?.${p.name}}">
                                <li class="list-group-item">
                                    <h4 id="${p.name}-label" class="list-group-item-heading"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></h4>
                                    <%  if (p.isEnum()) { %>
                                    <p class="list-group-item-text" aria-labelledby="${p.name}-label"><g:fieldValue bean="\${${propertyName}}" field="${p.name}"/></p>
                                    <%  } else if (p.oneToMany || p.manyToMany) { %>
                                    <g:each in="\${${propertyName}.${p.name}}" var="${p.name[0]}">
                                        <p class="list-group-item-text" aria-labelledby="${p.name}-label"><g:link controller="${p.referencedDomainClass?.propertyName}" action="show" id="\${${p.name[0]}.id}">\${${p.name[0]}?.encodeAsHTML()}</g:link></p>
                                    </g:each>
                                    <%  } else if (p.manyToOne || p.oneToOne) { %>
                                    <p class="list-group-item-text" aria-labelledby="${p.name}-label"><g:link controller="${p.referencedDomainClass?.propertyName}" action="show" id="\${${propertyName}?.${p.name}?.id}">\${${propertyName}?.${p.name}?.encodeAsHTML()}</g:link></p>
                                    <%  } else if (p.type == Boolean || p.type == boolean) { %>
                                    <p class="list-group-item-text" aria-labelledby="${p.name}-label"><g:formatBoolean boolean="\${${propertyName}?.${p.name}}" /></p>
                                    <%  } else if (p.type == Date || p.type == java.sql.Date || p.type == java.sql.Time || p.type == Calendar) { %>
                                    <p class="list-group-item-text" aria-labelledby="${p.name}-label"><g:formatDate date="\${${propertyName}?.${p.name}}" /></p>
                                    <%  } else if (!p.type.isArray()) { %>
                                    <p class="list-group-item-text" aria-labelledby="${p.name}-label"><g:fieldValue bean="\${${propertyName}}" field="${p.name}"/></p>
                                    <%  } %>
                                </li>
                            </g:if>
                            <%  } %>
                        </ol>
                        <g:form url="[resource:${propertyName}, action:'delete']" method="DELETE">
                            <fieldset>
                                <g:link class="btn btn-default" action="edit" resource="\${${propertyName}}"><g:message code="default.button.edit.label" default="Edit" /></g:link>
                                <g:actionSubmit class="btn btn-default" action="delete" value="\${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('\${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
                            </fieldset>
                        </g:form>
                    </div>
                </div>
            </div><!--/.col-xs-12.col-sm-9-->

            <div class="hidden-xs col-sm-3" id="sidebar">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="sidebar_1">
                            <h4 class="panel-title">
                                <a data-toggle="collapse" data-parent="#accordion" href="#collapse_1" aria-expanded="true" aria-controls="collapse_1">
                                    Actions
                                </a>
                            </h4>
                        </div>
                        <div class="panel-collapse collapse in" id="collapse_1" role="tabpanel" aria-labelledby="sidebar_1">
                            <ul class="list-group">
                                <li class="list-group-item"><g:link action="index"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
                                <li class="list-group-item"><g:link action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div><!--/.hidden-xs.col-sm-3-->
        </div>
    </div>
	</body>
</html>
